<?php

namespace App\Admin\Renderable;

use App\Models\UserIdentity;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class IdentityTable extends  LazyRenderable
{
    public function grid(): Grid
    {
        // 获取ID

        return Grid::make(new UserIdentity(['user:id,nickname,avatar','profession:id,name']),function (Grid $grid){
            $grid->disableActions();
            $grid->showRowSelector();
            $grid->column('user.avatar','用户头像')->image('',80,80);
            $grid->column('user.nickname','用户昵称');
            $grid->column('identity')
                ->using([1 => '讲师',2 => '顾问',3 => '名人']);
            $grid->column('profession.name','入驻行业');
            $grid->filter(function (Grid\Filter $filter){
                $filter->like('name',)->width(3);
                $filter->equal('corporate_phone','法人手机号')->width(3);
            });
        });
    }
}
